Skip to content

fix(api): let an artist download their own track with downloads off - #1033

Merged
dylanjeffers merged 1 commit into
mainfrom
fix/owner-download-own-track
Sep 4, 2026
Merged

fix(api): let an artist download their own track with downloads off#1033
dylanjeffers merged 1 commit into
mainfrom
fix/owner-download-own-track

Conversation

@dylanjeffers

Copy link
Copy Markdown
Contributor

Problem

Michael has flagged twice (June 25, today) that artists can't download their own tracks. Both reported tracks — kapyo x artikko - pasionaria (Rpd38wj) and Elequence - Novalunosis (r2Xp9aY) — have is_downloadable = false.

GET /v1/tracks/{id}/download serves track.Download, and dbv1.TracksKeyed only populates that field when rawTrack.IsDownloadable is true. There is no owner exception, so the edit page's Download File button — the one paired with Replace File, which exists precisely so an artist can retrieve what they uploaded — 404s for the owner and surfaces as the generic "Something went wrong. Please check your connection and storage and try again."

79 of 100 sampled trending tracks have downloads off, which matches the "most all tracks" in the report. The public download path itself is healthy: every sampled is_downloadable track returns 206 anonymously.

The original file is still there — GET /v1/tracks/Rpd38wj/inspect?original=true reports a 63 MB audio/wave blob on the content node. Nothing was lost; the API just refused to sign a link to it for the person who uploaded it.

Fix

When track.Download is nil, fall back to signing a link for a requester who proves — with the wallet signature already on the request — that they own the track or hold a grant on the account that does. Everyone else is unchanged: a stranger, signed or not, still gets the 404 the artist asked for by leaving downloads off.

Ownership is read from the recovered wallet rather than the user_id query param behind myId. user_id is the caller's own claim; it happens to be verified on this route today only because the route sits off authMiddleware's advisory-user_id allowlist, and an artist's original master should not depend on that list continuing to exclude it.

Also fixes the served filename for a case this change makes reachable: with no orig_file_cid the bytes are the mp3 transcode, so the name must not carry the uploaded file's extension — a .wav name on mp3 bytes is a file most editors refuse to open.

Tests

api/v1_track_download_test.go covers owner, manager-with-grant, anonymous, another wallet, and user_id spoofing both unsigned and signed by a stranger, plus the mp3 filename fallback. Full ./api/... suite passes (TestSearch needs Elasticsearch, unrelated).

🤖 Generated with Claude Code

The download endpoint only ever serves `track.Download`, which dbv1 populates
solely for tracks the public may download (`is_downloadable`). About four in
five tracks on the network have that off, and for those the artist's own
"Download File" button on the edit page - the one paired with "Replace File",
which exists precisely so an artist can retrieve what they uploaded - got a 404
and surfaced it as "Something went wrong. Please check your connection and
storage and try again."

Fall back to signing a link for a requester who proves, with the wallet
signature already on the request, that they own the track or manage the account
that does. Access for everyone else is unchanged: a stranger, signed or not,
still gets the 404 the artist asked for.

Ownership is read from the recovered wallet rather than the user_id query param
behind myId. user_id is the caller's own claim; it happens to be verified on
this route today only because the route sits off authMiddleware's advisory-
user_id allowlist, and an artist's original master should not depend on that
list continuing to exclude it.

Also fix the served filename for the case this now makes reachable: with no
orig_file_cid the bytes are the mp3 transcode, so the name must not carry the
uploaded file's extension - a .wav name on mp3 bytes is a file most editors
refuse to open.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@dylanjeffers
dylanjeffers merged commit c62f930 into main Sep 4, 2026
2 checks passed
@dylanjeffers
dylanjeffers deleted the fix/owner-download-own-track branch September 4, 2026 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant